# start_time = time.time()
# end_time = time.time()
# print('分类所用时间:', end_time - start_time)
import numpy as np

transform_matrix = np.array([[1.17382812, 0., 0.],
                    [0., 1.17382812, 163.0],
                    [0., 0., 1.]])

inverse_matrix = np.linalg.inv(transform_matrix)


def A2B(x, y):
    A = np.array([y, x, 1])  # 齐次坐标
    B_homogeneous = transform_matrix @ A
    y,x,_ = B_homogeneous
    return (x,y)


def B2A(x_prime, y_prime):
    B = np.array([y_prime, x_prime, 1])  # 齐次坐标
    A_homogeneous = inverse_matrix @ B
    return A_homogeneous[:2]


if __name__ == '__main__':
    print(A2B(0, 0)) #[0, 163]
    print(B2A(163, 0))

